﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.ComponentModel;

namespace Business
{
    public class Utilities
    {
        GetData data = new GetData();
        public DataTable DataHangBanTheoNgay(string ngay)
        {
            return data.DataHangBanTheoNgay(ngay);
        }
        public DataTable DataHangBanTheoThang(string thang)
        {
            return data.DataHangBanTheoThang(thang);
        }
        public string[] GetMaNV(string bophan)
        {
            string[] a = new string[MaNV(bophan).Rows.Count];
            for (int i = 0; i < MaNV(bophan).Rows.Count; i++)
            {
                a[i] = (MaNV(bophan).Rows[i][0].ToString());
            }
            return a;
        }
        private DataTable MaNV(string bophan)
        {
            return data.GetMaNV(bophan);
        }
        public string[] GetDanhMucMaDT(string bang)
        {
            string[] a = new string[MaDT(bang).Rows.Count];
            for (int i = 0; i < MaDT(bang).Rows.Count; i++)
            {
                a[i] = (MaDT(bang).Rows[i][0].ToString());
            }
            return a;
        }
        private DataTable MaDT(string bang)
        {
            return data.GetDanhMucMaDT(bang);
        }
        public DataTable GetDataTable(string bang)
        {
            return data.GetDataTable(bang);
        }
        public string Value(string tenbang, int hang, int cot)
        {
            return data.GetDataTable(tenbang).Rows[hang][cot].ToString();
        }
        public string CreateID(string Bang, string ChuoiPhu)
        {
            int tam = data.GetDataTable(Bang).Rows.Count;
            for (int i = 0; i<tam ; i++)
            {
                if (ChuoiPhu+i.ToString() != data.GetDataTable(Bang).Rows[i][0].ToString())
                    return ChuoiPhu + i.ToString();
            }
            return ChuoiPhu + tam.ToString();
        }
        public string[] GetHoaDon(string hoadon)
        {
            string[] a = new string[HoaDon(hoadon).Rows.Count];
            for (int i = 0; i < HoaDon(hoadon).Rows.Count; i++)
            {
                a[i] = (HoaDon(hoadon).Rows[i][0].ToString());
            }
            return a;
        }
        private DataTable HoaDon(string hoadon)
        {
            return data.GetDataTable(hoadon);
        }
        public string NgayBan(string iMEI)
        {
            return data.NgayBan(iMEI).Rows[0][0].ToString();
        }
        public string ThoiGianBaoHanh(string iMEI)
        {
            return data.ThoiGianBaoHanh(iMEI).Rows[0][0].ToString();
        }
    }
}
